/*
 *  POJ3267: The Cow Lexicon
 */

/*-------- Includes --------*/
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

/*-------- Defines --------*/


/*-------- Types --------*/


/*-------- Global Variables --------*/
int  W, L;
char msg[400];

vector<string> dict[128];

int dp[301];

/*-------- Function Prototypes --------*/


/*-------- Main Function --------*/
int main(int argc, char const *argv[])
{
    // get input
    cin >> W >> L;

    cin >> msg;

    char stmp[32];
    for (int i = 0; i < W; i++) {
        cin >> stmp;

        dict[stmp[0]].push_back(string(stmp));
    }

    // dynamic programming
    dp[L] = 0;

    for (int i = L - 1; i >= 0; i--) {
        dp[i] = dp[i + 1] + 1;

        // compare each word in dictionary
        int n = dict[msg[i]].size();

        for (int j = 0; j < n; j++) {
            string &s = dict[msg[i]][j];

            int len = s.length();

            if (len <= L - i) {
                int pm  = i + 1;
                int ps  = 1;

                while (pm < L && ps < len) {
                    if (msg[pm] == s[ps]) ps++;

                    pm++;
                }

                // match successfully
                if (ps == len)
                    dp[i] = min(dp[i], dp[pm] + pm - i - len);
            }
        }
    }

    cout << dp[0] << endl;

    return 0;
}

/*-------- Functions --------*/

